package form;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class SearchForm extends ActionForm {
	private static final Logger logger = Logger.getLogger(SearchForm.class);
	private static final String SEARCHFORM_INFO = "SearchForm is error"; 

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public SearchForm() {
		super();
	}

	private int id_routs;
	private int id_stantion; 
	private String searchFrom;
	private String searchTo;
	private String date_routs;
	private String name_routs;
	private String cityFrom;
	private String cityTo;

	 public ActionErrors validate(ActionMapping mapping,
	            HttpServletRequest request) {
	 
	        ActionErrors actionErrors = new ActionErrors();
	        try {
	        if(searchFrom == null || searchFrom.trim().equals("")) {
	            actionErrors.add("searchFrom", new ActionMessage("error.searchFrom"));
	        }
	        
	        if(date_routs == null || date_routs.trim().equals("")) {
	            actionErrors.add("date_routs", new ActionMessage("error.date_routs"));
	        }
	        
	        
	        if(searchTo == null || searchTo.trim().equals("")) {
	            actionErrors.add("searchTo", new ActionMessage("error.searchTo"));
	        }
	        }catch(Exception e) {
	        	logger.error(SearchForm.SEARCHFORM_INFO + e.getMessage());
	        }
	        return actionErrors ;
	    }
	
	public String getSearchTo() {
		return searchTo;
	}

	public void setSearchTo(String searchTo) {
		this.searchTo = searchTo;
	}

	public int getId_stantion() {
		return id_stantion;
	}

	public void setId_stantion(int id_stantion) {
		this.id_stantion = id_stantion;
	}

	public int getId_routs() {
		return id_routs;
	}

	public void setId_routs(int id_routs) {
		this.id_routs = id_routs;
	}

	public String getSearchFrom() {
		return searchFrom;
	}

	public void setSearchFrom(String searchFrom) {
		this.searchFrom = searchFrom;
	}

	public String getDate_routs() {
		return date_routs;
	}

	public void setDate_routs(String date_routs) {
		this.date_routs = date_routs;
	}

	public String getName_routs() {
		return name_routs;
	}

	public void setName_routs(String name_routs) {
		this.name_routs = name_routs;
	}

	public String getCityFrom() {
		return cityFrom;
	}

	public void setCityFrom(String cityFrom) {
		this.cityFrom = cityFrom;
	}

	public String getCityTo() {
		return cityTo;
	}

	public void setCityTo(String cityTo) {
		this.cityTo = cityTo;
	}
}
